﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using The_Chronicles_of_Asku.Characters.Mobs;
using The_Chronicles_of_Asku.Areas.End_Game_Floors.Dungeon_One.Floors_6_10.Resources;
using The_Chronicles_of_Asku.Characters;

namespace The_Chronicles_of_Asku.Areas.End_Game_Floors
{
    class EndlessFloorOne
    {
        Battle battle = new Battle();
        Skeleton skel = new Skeleton();
        Necromancer necro = new Necromancer();
        Undead zombie = new Undead();
        SetMobLevels setLevel = new SetMobLevels();
        Hero myHero = new Hero();
        Villager villager = new Villager();



        public void theFloor(Hero myHero, Mob mob)
        {
            setLevel.setMobLevelFiftyTierSeven(skel, necro, zombie, villager);
            int survival = 0;

            while (myHero.isAlive && myHero.hasFled == false)
            {
                Random rnd = new Random();
                int roll = rnd.Next(1, 5);
                switch (roll)
                {
                    case 1:
                        SkeletonFight(myHero, skel);
                        break;

                    case 2:
                        NecromancerFight(myHero, necro);
                        break;

                    case 3:
                        UndeadFight(myHero, zombie);
                        break;

                    case 4:
                        VillagerFight(myHero, villager);
                        break;

                    default:
                        Console.WriteLine("Something went terribly wrong.");
                        break;
                }

                survival++;
                if (survival > myHero.highestSurvival)
                {
                    myHero.highestSurvival = survival;
                }
            }

            if (myHero.isAlive == false)
            {
                myHero.isAlive = true;
            }
        }

        private void UndeadFight(Hero myHero, Undead zombie)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, zombie);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            zombie.ResetStats(zombie);

            Console.Clear();
        }

        private void SkeletonFight(Hero myHero, Skeleton skel)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, skel);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            skel.ResetStats(skel);

            Console.Clear();
        }

        private void NecromancerFight(Hero myHero, Necromancer necro)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, necro);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            necro.ResetStats(necro);

            Console.Clear();
        }

        private void VillagerFight(Hero myHero, Villager villager)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, villager);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            villager.ResetStats(villager);

            Console.Clear();
        }

        private void ClearScreen()
        {
            Console.ReadKey();
            Console.Clear();
        }
    }
}
